install_sh = @install_sh@
mkdir_p = @mkdir_p@
INSTALL = @INSTALL@
VIEWERDIR = @prefix@/viewer
CP = /bin/cp
INSTALL_BUNDLE ?= "bundle:min"


all: molochparser.js

molochparser.js: molochparser.jison
	jison molochparser.jison

check:
	npm ci
	npm run bundle

install:
	@mkdir -p "$(VIEWERDIR)" "$(VIEWERDIR)/vueapp"
	/bin/rm -f $(VIEWERDIR)/public/style.css
	$(INSTALL) *.js package.json package-lock.json $(VIEWERDIR)
	npm ci
	npm run $(INSTALL_BUNDLE)
	(cd public ; wget -N https://github.com/gchq/CyberChef/releases/download/v9.28.0/CyberChef_v9.28.0.zip)
	$(CP) -pr views public $(VIEWERDIR)
	$(CP) -pr vueapp/dist "$(VIEWERDIR)/vueapp"
	(cd $(VIEWERDIR) ; npm ci --production)
	rm -f $(VIEWERDIR)/package-lock.json

distclean realclean clean:
	rm -rf node_modules
	rm -rf bundle
	(cd vueapp ; rm -rf node_modules ; rm -rf dist)
